[PATCH] lib-regex: Set DREGEX_MAX_MATCHES to library default
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 22 Dec 2025 09:05:31 +0000 (11:05 +0200)
committerNoah Meyerhans <noahm@debian.org>
Wed, 4 Feb 2026 16:09:21 +0000 (11:09 -0500)
Gbp-Pq: Name lib-regex_Set_DREGEX_MAX_MATCHES_to_library_default.patch

src/lib-regex/regex.c
src/lib-regex/test-regex.c

index 51e7d6c5130656d8d0d624340b1af1d73f469031..5ccf9d54bedad4f33f40e1d3f2c238531bf09009 100644 (file)
@@ -14,7 +14,7 @@
 #include "pcre2.h"
 
 #define DREGEX_MAX_DEPTH 100
-#define DREGEX_MAX_MATCHES 100
+#define DREGEX_MAX_MATCHES 10000000
 #define DREGEX_MAX_CAPTURE_GROUPS 100
 #define DREGEX_MAX_CPU_SECONDS 1
 
index 10b393e409ef8a3faac6092f9dfda134d94d8e02..4b68bca2cebf2e30260803dcf335d4c3c15e43bb 100644 (file)
@@ -158,19 +158,21 @@ static void test_dregex_match(void)
                        "{1}[a-z0-9]+[.]{1}(([a-z]{2,3})|([a-z]{2,3}[.]"
                        "{1}[a-z]{2,3}))$",
                        "thisisabstractly.andtotally.long.email@"
-                       REP10("a") "." REP10("a") "." REP10("a")
+                       REP10(REP10("a") "." REP10("a") "." REP10("a") "." REP10("a"))
                        ".has",
-                       "match limit exceeded",
+                       "matching depth limit exceeded",
                        0,
                        -1
                ),
                MATCH_CASE_FULL(
                        "(a|a?)+",
-                       REP10("a") REP10("a"),
-                       "match limit exceeded",
+                       REP10(REP10("a") REP10("a") REP10("a")),
+                       "matching depth limit exceeded",
                        0,
                        -1
                ),
+               /* Live test cases */
+               MATCH_CASE("\\[.*PATCH.*\\]", "Subject: Re: [PATCH v2 3/6] arm64: dts: qcom: qcm6490-shift-otter: Ad"),
                /* IEEE.1003-2.1992 */
                MATCH_CASE("me(\\+.*)?@company\\.com",
                        "me+hello@company.com"),